export const timeCalc = (time) => {
    let now = new Date();
    let date = new Date(time);
    let diff = now.getTime() - date.getTime();
    let day = (date.getMonth() + 1) + '-' + (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' · '
    if (diff < 1000 * 60) {
        return '刚刚';
    } else if (diff < 1000 * 60 * 60) {
        return day + Math.floor(diff / (1000 * 60)) + '分钟前';
    } else if (diff < 1000 * 60 * 60 * 24) {
        return day + Math.floor(diff / (1000 * 60 * 60)) + '小时前';
    } else if (diff < 1000 * 60 * 60 * 24 * 30) {
        return day + Math.floor(diff / (1000 * 60 * 60 * 24)) + '天前';
    } else if (diff < 1000 * 60 * 60 * 24 * 30 * 12) {
        return day + Math.floor(diff / (1000 * 60 * 60 * 24 * 30)) + '月前';
    } else {
        return day + Math.floor(diff / (1000 * 60 * 60 * 24 * 30 * 12)) + '年前';
    }
}